#ifndef CORE_GLDRAWER_H
#define CORE_GLDRAWER_H

#include <map>
#include "Drawing/IDrawer.h"
#include "Common/Algebra/Vec2.h"
#include "GameCore/Texture.h"

namespace core {

	class GlDrawer : public drawing::IDrawer
	{
	public:
		GlDrawer( const drawing::Color& backgroud );
		virtual ~GlDrawer();

	// hiding copy constructor and assignment operator:
	// only one instance if GlDrawer should exist at the same time
	private:
		GlDrawer( const GlDrawer& other );
		GlDrawer& operator=( const GlDrawer& other );

	public:
		virtual drawing::Pen GetPen() const;
		virtual void SetPen( const drawing::Pen& pen );

		virtual drawing::Brush GetBrush() const;
		virtual void SetBrush( const drawing::Brush& brush );

		virtual void DrawPoint( const cmn::Vec2& point );
		virtual void DrawLine( const cmn::Vec2& start, const cmn::Vec2& end );

		virtual void DrawCircle( const cmn::Circle& circle );
		virtual void DrawPolygon( const cmn::Polygon& polygon );

		virtual void DrawModel( const cmn::Transform& position, const drawing::Model* model );

	private:
		void UsePen( const drawing::Pen& pen );
		void UseBrush( const drawing::Brush& brush );

		void UsePenStyle( drawing::PenStyle penStyle );
		void UseBrushStyle( drawing::BrushStyle brushStyle );

		void UseColor( const drawing::Color& color );

		static Texture GetTexture( std::string textureFilename );

	private:
		drawing::Pen m_pen;
		drawing::Brush m_brush;

		static std::map<std::string, Texture> m_textureStore;

		static GLubyte horizontalHatch[128];
		static GLubyte verticalHatch[128];
		static GLubyte crossHatch[128];
		static GLubyte leftDiagHatch[128];
		static GLubyte rightDiagHatch[128];
		static GLubyte crossdiagHatch[128];
		static GLubyte stipple[128];
	};
}

#endif // CORE_GLDRAWER_H
